// SPDeployExt.h : Declaration of the CSPDeployExt

#pragma once
#include "resource.h"       // main symbols

#include "SPDeploymentExtension_i.h"
#include <shlobj.h>
#include <comdef.h>
#include <string>

#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif

using namespace std;

// CSPDeployExt

class ATL_NO_VTABLE CSPDeployExt :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CSPDeployExt, &CLSID_SPDeployExt>,
	public IShellExtInit,
	public IContextMenu
{
public:
	
	//	Enumeration for actions that can be performed.
	enum Action
	{
		AddSolution,
		UpgradeSolution,
		DeploySolution,
		AddAndDeploySolution
	};

	CSPDeployExt()
	{
	}

DECLARE_REGISTRY_RESOURCEID(IDR_SPDEPLOYEXT)

DECLARE_NOT_AGGREGATABLE(CSPDeployExt)

BEGIN_COM_MAP(CSPDeployExt)
	COM_INTERFACE_ENTRY(IShellExtInit)
	COM_INTERFACE_ENTRY(IContextMenu)
END_COM_MAP()



	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

private:
	void DeploySolutionFile(TCHAR[MAX_PATH], UINT);
	wstring GetAddSolutionArgs(TCHAR[MAX_PATH]);
	wstring GetUpgradeSolutionArgs(TCHAR[MAX_PATH]);
	wstring GetDeploySolutionArgs(TCHAR[MAX_PATH]);

protected:
	//	Stores filename selected in explorer.
	TCHAR _fileName[MAX_PATH]; 

public:
	//	IShellExtInit
	STDMETHODIMP Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY);

	//	IContextMenu
	STDMETHODIMP GetCommandString(UINT_PTR, UINT, UINT*, LPSTR, UINT);
	STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO);
	STDMETHODIMP QueryContextMenu(HMENU, UINT, UINT, UINT, UINT);

};

OBJECT_ENTRY_AUTO(__uuidof(SPDeployExt), CSPDeployExt)
